sugar_path
Sugar functions for manipulating paths.
Main functionalities
- SugarPath::as_path makes it easy to convert
T: Deref<Target = str>
toPath
and allows you to use methods ofSugarPath
on&str
orString
directly.
use Path;
use SugarPath;
assert_eq!;
assert_eq!;
- SugarPath::to_slash/SugarPath::to_slash_lossy allows you to convert the path to the string with consistent slash separator on all platforms.
use SugarPath;
let p = "./hello/world".as_path;
let p = ".\\hello\\world".as_path;
assert_eq!;
assert_eq!;
- SugarPath::normalize allows you normalize given path by dropping unnecessary
.
or..
segments.
use Path;
use SugarPath;
assert_eq!;
- SugarPath::relative allows you to get the relative path from the given path to the target path.
use SugarPath;
assert_eq!;
assert_eq!;
- SugarPath::absolutize is a shortcut of SugarPath::absolutize_with with passing
std::env::current_dir().unwrap()
as the base path.
use SugarPath;
let cwd = current_dir.unwrap;
assert_eq!;
- SugarPath::absolutize_with allows you to absolutize the given path with the base path.
use SugarPath;
- For more details, please refer to the SugarPath.